home *** CD-ROM | disk | FTP | other *** search
- Inliner
-
- Version 1.00 File: INLINER.PAS
- Last revised: 12 Apr 1985 Author: Anthony M. Marcy
-
- DESCRIPTION
-
- Inliner is an assembler which translates 8088 assembly language directly
- into Turbo Pascal INLINE code. It is written in, and generates code for,
- Turbo Pascal 2.00 for the IBM PC. This program is in the public domain.
- Inliner accepts a source language similar, but not identical, to that
- of the IBM Macro Assembler (MASM). It produces a single Turbo INLINE statement
- ready to be merged into a Pascal program or used as an Include file.
- All 8088 instructions are supported. MASM pseudo-ops are not, and there
- are a few differences in syntax between Inliner and MASM, as detailed below.
- System requirements are those for running Turbo. If you can compile
- Inliner, you can run it. (If you can't compile it, you don't need it.)
- Maximum assembly program size is set by the size of memory. Inliner can use
- all available contiguous memory.
- The new version 3.00 of Turbo has changes to the INLINE statement which
- make it not always compatible with code written for Turbo 2.00. Inliner 1.00
- is designed to work with Turbo 2.00. In particular, assembly programs which
- contain both labels and constant identifiers, and assembled by Inliner, may
- not compile correctly under Turbo 3.00.
-
- GETTING STARTED
-
- You will be prompted for a source file and a target file. If no source
- filename extension is given, .ASM is assumed. The default target file is
- your source filename with extension .PAS; a carriage return accepts the
- default, or you may enter any legal filename.
- Quick trick: entering TRM: as the source file will allow you to type your
- input directly into Inliner. It will not be saved, however, and no editing
- is available. End your input with ctrl-z. Entering NUL as the target file
- will cause no output file to be generated, but you can still see the output
- on the screen. Handy if you just need a line or two, or for testing what
- will "work".
- Inliner may also be started from the DOS command line, thus:
- A> inliner infile.asm outfile.pas
- The second parameter may be omitted, in which case the default is assumed.
-
-
- INSTRUCTION FORMAT
-
- An Inliner source line takes the general form:
- label: opcode operand, operand ;comment
- Each of these components is optional.
-
- A LABEL can be anything that would be legal as a Turbo identifier, limited
- in length to a maximum of twenty characters. The colon is mandatory after
- a label.
-
- OPCODEs are the standard Intel mnemonics. LOCK and the various REP
- prefixes are supported. The segment override prefix can only be placed before
- an operand, not before the opcode.
-
- OPERANDs can be of three general kinds: register, address, and immediate.
- Register operands are the usual mnemonics - AX,BX, etc.
- Address operands have the following form:
- prefix: (type) [base] [index] offset
- Each component is optional. The ordering is strict.
- prefix is a segment override -- DS, CS, SS, or ES
- type is a single letter -- N Near
- F Far
- S Short
- W Word
- B Byte
- base is a base register -- BX or BP
- index is an index register -- SI or DI
- offset is either a literal constant or a Turbo identifier
-
- Turbo identifiers are copied into the INLINE code. Any identifier which does
- not occur as a label is assumed to be a Turbo identifier. The compiler replaces
- variable names with their offsets within their segments; it replaces constant
- identifiers with their values. The location counter, *, is also legal. See
- the Turbo manual for details.
- ADD AL,var1 ;var1 is a global variable in the data segment
- ADD AL,[BP]var2 ;var2 is a local variable in the stack segment
- ADD AL,CS:var3 ;var3 is a typed constant in the code segment
-
- Immediate operands are distinguished by being prefixed with an equal sign.
- They may be constants or Turbo variables. Thus,
- MOV AX,=2 ;loads the value 2 into AX
- MOV AX,2 ;loads AX with the word at offset 2 in the data segment
- MOV AX,var1 ;loads AX with the contents of variable var1
- MOV AX,=var1 ;loads the offset of variable var1 into AX
- The equal sign is optional in the INT, RET, IN, and OUT instructions, and
- before character literals.
-
- CONSTANTs can be decimal integers (positive or negative), hex constants
- in Turbo format (preceded by $), constant identifers, or character literals
- enclosed in single quotes. Examples: 2 -128 $FF cons 'x'
- The type must be specified when it cannot otherwise be deduced:
- ADD AX,[BP]2 ;AX - must be a word operand
- INC (W)[BP]2 ;requires (W) or (B)
- Immediate numeric constants default to (B)yte if in the range -128..255,
- otherwise (W)ord.
-
- JMP requires special treatment. A (F)ar jump to an absolute address may be
- coded with two operands, both immediate constants, representing the segment
- and the offset:
- JMP =$0060,=$0100 ;absolute address 0060:0100
- A (N)ear jump to an offset in the CS requires a single immediate operand:
- JMP =$0100 ;address CS:0100
- JMP =*-1 ;this instruction jumps to itself
- An indirect jump takes either a register or an address operand. In the latter
- case, the type must be specified:
- JMP AX ;must be (N)ear
- JMP (F)[BP][SI]
- JMP (N)var1
- Lastly, the jump target may be an Inliner label. For forward references,
- more efficient code can be generated if (S)hort is specified when possible:
- JMP lab1
- JMP (S)lab2
-
- CALL is similar to JMP, except that (S)hort cannot be used.
-
- The conditional jump instructions -- JE, JNE, etc. -- take a single
- operand which may be either an immediate constant in the range -128..127
- or an Inliner label.
-
- The string instructions vary slightly from MASM syntax. REP, REPZ, etc.,
- are considered prefixes which must be placed before a string opcode on the
- same line. The special no-operand forms of the string opcodes -- MOVSB,
- MOVSW, etc. -- are not implemented. Instead, use the basic opcode with
- a type specifier. The full two-operand forms may also be written.
- REP CMPS (B)
- REP MOVS (W)[SI],[DI]
-
- Other instructions resemble their counterparts in MASM. Refer to the
- Macro Assembler manual for their formats. Inliner does not support any
- pseudo-ops, such as PROC, END, DW, or ASSUME. Nor does it support the
- 8087 mnemonics.
- Pascal declarations should be used to define data, in place of DB, DW,
- EQU, etc. But remember that your variables are Turbo variables -- Inliner
- cannot see your declarations to check type or addressibility. You must
- provide segment overrides where needed.
-
-
- EXAMPLES
-
- Here are some more examples of Inliner code:
-
- PUSH BP
- h2: CMP var1,=-1 ;byte variable assumed
- CMP var1,(W)=-1 ;unless overridden
- MOV var2,=var4 ;address is always two bytes
- JE (S)h5
- REPE SCAS(B) ;instead of SCASB
- shl ax,cl ;lower case is OK
- ESC = 23 , [ DI ] var2 ;spaces are OK, too
- MOV ES:4,'&'
- h5: SUB (W)var3,=$40
- NOP
- CALL (N)xyz ;indirect through variable xyz
- ;unless xyz is a label
- MOV [BX][DI],CS
- RET (N) 4 ;(N) or (F) required
-
- -----------------------------------------------------------------
-
- Inliner is supported on the RBBS-PC operated by
- James Miles
- "The Programmer's Toolbox"
- (301) 540-7230 (data)
- 24 Hrs.
- Comments, bug reports, and suggested improvements are encouraged. Address
- them to ANTHONY MARCY or to SYSOP. If you make extensions or revisions
- to this program, please upload so that all may share.
-
- Enjoy!
-